﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

/* 
  *  自动失色的按钮控件
  *  创建时间：2019/12/19 wj
  *  修改时间：2019/12/19 wj
  */
namespace Demo.Control
{
    public class ColorButton : System.Windows.Forms.Button
    {
        // 未锁定颜色，与控件背景颜色一致
        public Color UnLockedColor
        {
            get { return this.BackColor; }
            set 
            {
                this.BackColor = value; 
            }
        }

        // 锁定后颜色，另外设定
        private  Color lockedColor;
        public Color LockedColor
        {
            get { return lockedColor; }
            set 
            {  
                lockedColor = value; 
            }
        }

        protected override void WndProc(ref System.Windows.Forms.Message msg)
        {
            if (Enabled)
            {
                this.BackColor = UnLockedColor;
            }
            else
            {
                this.BackColor = LockedColor;
            }
            base.WndProc(ref msg);
        }
    }
}
